var Physics = {
	addNeutonian:function(obj){
		obj.x = 100;
		obj.y = 100;
		obj.v = 0;
		obj.a = 0;
		obj.aV = 0;
		obj.update = function(){
			var update = Physics.getPositionUpdate(this.a,this.v);
			this.x += update.x;
			this.y += update.y;
			this.a += this.aV;
			// correct angle to be within 0-360
			if(this.a > 360){
				this.a -= 360;
			} else if (this.a < 0){
				this.a += 360;
			}			
			if("onUpdate" in this){
				this.onUpdate();
			}
		};
		obj.speedUp = function(){
			if(this.v < this.vMax){
				this.v += this.accel;
			}
		};
		obj.speedDown = function(){
			if(this.v > this.vMin){
				this.v -= this.decel;
			}
		};
		obj.turnRight = function(){
			if(this.aV < this.angleAccelMax){
				this.aV += this.angleAccel;
			}
		};
		obj.turnLeft = function(){
			if(this.aV > -this.angleAccelMax){
				this.aV -= this.angleAccel;
			}
		};
		obj.getHardpoint = function(x,y){ // returns the canvas x,y relative to the object with respect to height and width
			// 0,0 is the top left hand corner of the object, if it is pointing at 0 degrees.
			// to get the bottom right hand corner of an object with height 16 and width 8, pass in x = 8, y = 16
			var result = {
				x:this.x+obj.width/2,
				y:this.y+obj.height/2
			};
			return result;
		}
		return obj;
	},
	getPositionUpdate:function(a,v){ // gets the x/y delta based on angle and velocity
		var sin = Math.sin(a * Math.PI /180);
		var cos = Math.cos(a * Math.PI /180);
		var vY = cos * v * -1;
		var vX = sin * v;
		return {x:vX,y:vY};
	}
};